'use strict'

module.exports = angular.module 'services.messagePush', [
  require 'angular-resource'
  require('constant').name
  require('baseService').name
]
.factory "MessagePushService", ($log, $resource, $q, Constant, BaseService)->
  $log.log "messagePush service init"
  class MessagePushService

    constructor: ->
      @baseService = new BaseService()
      constant = new Constant()
      operationDomain = constant.OPERATION_DOMAIN
      $log.log "operationDomain:",operationDomain
      @messagePushService = $resource "#{operationDomain}/passport/message/job/:id", null, {post: {method: 'POST'}, update: {method: 'PUT'}}

    list: (params, successCb, errorCb)->
      return if !successCb
      promise = @messagePushService.get( params ).$promise
      @baseService.deal promise, successCb, errorCb

    get: (params, successCb, errorCb)->
      return if !successCb
      promise = @messagePushService.get( params ).$promise
      @baseService.deal promise, successCb, errorCb

    new: (data, successCb, errorCb)->
      return if !successCb
      promise = @messagePushService.post(data).$promise
      @baseService.deal promise, successCb, errorCb

    update: (params, data, successCb, errorCb)->
      return if !successCb
      promise = @messagePushService.update( params, data ).$promise
      @baseService.deal promise, successCb, errorCb